package com.elibrary;

import android.app.Application;
import android.content.Context;
import com.elibrary.imageloader.ImageLoader;

/**
 * Created with IntelliJ IDEA.
 * User: Enkuso
 * Date: 12/11/12
 * Time: 3:01 PM
 * To change this template use File | Settings | File Templates.
 */
public class BookstoreApplication extends Application {

    // Defining global variables
    private boolean isLogged;
    private String userToken;
    public ImageLoader imageLoader;

    private static Context context;

    @Override
    public void onCreate() {
        isLogged = false;
        super.onCreate();
        BookstoreApplication.context = getApplicationContext();
        imageLoader = new ImageLoader(context);
    }

    public static Context getAppContext() {
        return BookstoreApplication.context;
    }

    public boolean isLogged() {
        return isLogged && userToken != null;
    }

    public void setLogged(boolean logged) {
        isLogged = logged;
    }

    public void setLoggedIn(String token) {
        isLogged = true;
        userToken = token;
    }

    public void setLoggedOut() {
        isLogged = false;
        userToken = null;
    }

    public String getUserToken() {
        return userToken;
    }

    public void setUserToken(String userToken) {
        this.userToken = userToken;
    }
}
